#include "PhysicsCalculations.h"
#include "Timer.h"
#include "Vec3.h"

// Verlet 
void CalculatePositionV(D3DXVECTOR3& currentPosition, D3DXVECTOR3& oldPosition, 
	const D3DXVECTOR3& acceleration)
{
	float dt = TheTimer::Instance()->GetDt();
	D3DXVECTOR3 difference = (currentPosition + acceleration) * (dt * dt);
	oldPosition = currentPosition;
	currentPosition += difference;
}

// Euler
void CalculatePositionE(D3DXVECTOR3& currentPosition, D3DXVECTOR3& oldVelocity, 
	D3DXVECTOR3& velocity, const D3DXVECTOR3& acceleration)
{
	float dt = TheTimer::Instance()->GetDt();
	oldVelocity = velocity;
	velocity += acceleration * dt;
	velocity *= 0.999f;
	currentPosition += 0.5f * ((oldVelocity + velocity) * dt);
}

// D'Almbert's
void CalculateForce(D3DXVECTOR3& currentForce, const D3DXVECTOR3& actingForce)
{
	currentForce += actingForce;
}